<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>登录</title>
<link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/css/layui.css}" />
<link rel="stylesheet" th:href="@{/src/lvdong/origin/css/login.css}">
<link rel="stylesheet" th:href="@{/src/xxy/css/xxy.css}">

</head>

<body>
		<!-- 商家码登陆表单 -->
		<div class="site-text " style="margin: 5%; display: none" id="window"  target="test123">	
	<form class="layui-form" id="book" method="post" lay-filter="example">
	 
	    <div  class="layui-input-block">
	      <input type="text" id="store_key" name="store_key"  lay-verify="title" autocomplete="off" placeholder="请输入唯一商家码" class="layui-input">
	    </div>
	 
	  </form>
	  </div>
	<div class="kit-login">
		<div class="kit-login-bg"></div>
		<div class="kit-login-wapper">
			<h2 class="kit-login-slogan">
				欢迎使用 <br> 文旅乐园商家管理系统
			</h2>
			<div class="kit-login-form">
				<h4 class="kit-login-title">登录</h4>
				<form class="layui-form" method="post">
					<div class="kit-login-row">
						<div class="kit-login-col">
							<i class="layui-icon">&#xe612;</i>
							<span class="kit-login-input">
								<input type="text" name="user_id" lay-verify="required" placeholder="账号" />
							</span>
						</div>
						<div class="kit-login-col"></div>
					</div>
					<div class="kit-login-row">
						<div class="kit-login-col">
							<i class="layui-icon">&#xe64c;</i>
							<span class="kit-login-input">
								<input type="password" name="password" lay-verify="required" placeholder="密码" />
							</span>
						</div>
						<div class="kit-login-col"></div>
					</div>
					<div class="kit-login-row">
						<div class="kit-login-col">
							<input type="checkbox" name="rememberMe" title="记住帐号" lay-skin="primary">
						</div>
					</div>
					<div class="kit-login-row">
						<button class="layui-btn kit-login-btn" lay-submit="submit" lay-filter="login_hash">登录</button>
					</div>
					<div class="kit-login-row float-left" style="margin-bottom: 0;">
						<a href="javascript:;" style="color: rgb(153, 153, 153); text-decoration: none; font-size: 13px;" id="forgot">忘记密码,或首次登陆</a>
					</div>
				</form>
			</div>
		</div>
	</div>

	<script type="text/jscript" th:src="@{/plugin/layui/layui.js}" charset="UTF-8"></script>
	<script type="text/jscript" th:src="@{/plugin/jquery/jquery.min.js}"></script>
	<script  th:inline="none">
		layui.use([ 'layer', 'form' ], function() {
			var form = layui.form, $ = layui.jquery;

			$('#forgot').on('click', function() {
				layer.open({
		        	type: 1 
		               ,title: ['登陆']
		               ,btn: ['登陆', '取消'] 
				       ,area: ['500px', '200px']
		               ,shadeClose: true
		               ,shade: 0 
		               ,maxmin: true 
		               ,content: $("#window")
		               ,yes:function(index,layero){
		            	   $.getJSON("/store/user/loginByKey",{
		            		   store_key: $('#store_key').val(),
		            	   },function(data){
		            		  if(data.code==0){
		            			  alert(data.msg);
		            			  layer.close(index);
		            			  window.location.href="/toMain"
		            		  }else{
		            			  alert(data.msg);
		            		  }
		            	   })
		               }
		        });

				
				
				
				
			});
			//监听提交
			form.on('submit(login_hash)', function(data) {
// 				layer.msg(JSON.stringify(data.field));
				$.ajax({
					url:"/store/user/login",
					type:"post",
					data:data.field,
					success:function(data){
						if(data.code==0){
	            			  alert(data.msg);
	            			  window.location.href="/toMain"
	            		  }else{
	            			  alert(data.msg);
	            		  }
					}
				})
				
// 				setTimeout(function() {
// 					location.href = '/user/login.do';
// 				}, 1000);

				return false;
			});
		});
	</script>
</body>

</html>